package com.tian.system.controller;

import java.util.List;

import com.tian.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.tian.system.domain.UserRole;
import com.tian.system.service.IUserRoleService;

/**
 * 用户对应角色表 信息操作处理
 *
 * @author zcx
 * @date 2019-12-09 15:30:56
 */
@Controller
@RequestMapping("/system/userRole")
public class UserRoleController {
    private String prefix = "system/userRole";

    @Autowired
    private IUserRoleService userRoleService;

    /**
     * 查询用户对应角色表列表
     */
    @PostMapping("/list")
    @ResponseBody
    public String list(UserRole userRole) {
        AjaxResult ajaxResult = new AjaxResult();
        List<UserRole> list = userRoleService.selectUserRoleList(userRole);
        return ajaxResult.success(list);
    }

    /**
     * 新增保存用户对应角色表
     */
    @PostMapping("/add")
    @ResponseBody
    public String addSave(UserRole userRole) {
        AjaxResult ajaxResult = new AjaxResult();
        return ajaxResult.success(userRoleService.insertUserRole(userRole));
    }

    /**
     * 修改保存用户对应角色表
     */
    @PostMapping("/edit")
    @ResponseBody
    public String editSave(UserRole userRole) {
        AjaxResult ajaxResult = new AjaxResult();
        return ajaxResult.success(userRoleService.updateUserRole(userRole));
    }

    /**
     * 删除用户对应角色表
     */
    @PostMapping("/remove")
    @ResponseBody
    public String remove(String ids) {
        AjaxResult ajaxResult = new AjaxResult();
        return ajaxResult.success(userRoleService.deleteUserRoleByIds(ids));
    }

}
